package com.git.hui.yinshua.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yihui
 * @date 24/06/07
 */
public class MapUtil {

    public static Long getLong(Map<String, Object> map, String key) {
        return Long.valueOf(String.valueOf(map.get(key)));
    }

    public static Integer getInteger(Map<String, Object> map, String key) {
        return Integer.valueOf(String.valueOf(map.get(key)));
    }

    public static String getStr(Map<String, Object> map, String key) {
        return String.valueOf(map.get(key));
    }

    public static <K, V> Map<K, V> newMap(K k, V v, Object... kv) {
        Map<K, V> map = new HashMap<>(kv.length + 1);
        map.put(k, v);
        for (int i = 0, len = kv.length; i < len; i += 2) {
            map.put((K) kv[i], (V) kv[i + 1]);
        }
        return map;
    }
}
